home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / os20 / wb / tm_tools.lha / tm_tools / GAsk.c < prev    next >
C/C++ Source or Header  |  1992-11-01  |  2KB  |  81 lines

  1. ;/* GAsk - compiles with SAS/C 5.10a by executing this file
  2. lc -cfis -v -b0 -iinclude:intui.sym -iinclude:pragmas.sym -O -j73 GAsk
  3. blink GAsk.o to GAsk
  4. quit ;*/
  5. /*
  6. *    GAsk
  7. *
  8. *    Simple Ask substitute, puts requester up rather than
  9. *    a prompt at the Shell. Needs OS2.0+
  10. *
  11. *        RC=5 if YES,
  12. *        RC=0 if NO.
  13. *
  14. *    Martin W. Scott, Sunday 01-Nov-92.
  15. */
  16. #include <exec/types.h>
  17. #include <dos/dos.h>
  18. #include <dos/rdargs.h>
  19. #include <intuition/intuition.h>
  20. #include <proto/exec.h>        /* use PRAGMAS */
  21. #include <proto/dos.h>
  22. #include <proto/intuition.h>
  23.  
  24. #define PROJECT    "GAsk"    /* program name */
  25. #define ARGSTR    "PROMPT/A/F"    /* argument template */
  26. #define NARGS    1    /* number of args in template */
  27. #define PROMPT    0
  28.  
  29. LONG    main(void);        /* prototypes */
  30.  
  31. const char version_str[] = "$VER: GAsk 1.0";
  32. struct DosLibrary *DOSBase;
  33. struct IntuitionBase *IntuitionBase;
  34.  
  35. BOOL Confirm(char *);
  36.  
  37. LONG main(void)        /* entry: GAsk */
  38. {
  39.     struct RDArgs *readargs;
  40.     LONG rargs[NARGS];
  41.     LONG rc = 20;
  42.  
  43.     if (DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 37L))
  44.     {
  45.         if (readargs = ReadArgs(ARGSTR, rargs, NULL))
  46.         {
  47.             if (Confirm((char *)rargs[PROMPT]))
  48.                 rc = 5;
  49.             else
  50.                 rc = 0;
  51.         }
  52.         else PrintFault(IoErr(), PROJECT);
  53.  
  54.         CloseLibrary(DOSBase);
  55.     }
  56.  
  57.     return rc;
  58.  
  59. } /* main */
  60.  
  61. BOOL
  62. Confirm(char *str)
  63. {
  64.     struct EasyStruct es;
  65.     BOOL success = FALSE;
  66.  
  67.     if (IntuitionBase = (void *)OpenLibrary("intuition.library", 37L))
  68.     {
  69.         es.es_StructSize = sizeof(struct EasyStruct);
  70.         es.es_Flags = 0;
  71.         es.es_Title = "Confirm:";
  72.         es.es_TextFormat = str;
  73.         es.es_GadgetFormat = "Yes|No";
  74.         success = EasyRequestArgs(NULL, &es, NULL, NULL);
  75.  
  76.         CloseLibrary(IntuitionBase);
  77.     }
  78.  
  79.     return success;
  80. }
  81.